/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

/**
 *
 * @author kayman
 */
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.URL;
import javax.imageio.*;
import javax.swing.*;
 
/**
 * This class demonstrates how to load an Image from an external file
 */
public class Imagen extends Component {
           
    BufferedImage img;
    
    public void paint(Graphics g) {
        g.drawImage(img, 0, 0, null);
    }
 
    public Imagen(String file) {
        URL url = getClass().getResource(file);
       try {
           img = ImageIO.read(url);
       } catch (IOException e) {
       }
 
    }
 
    public Dimension getPreferredSize() {
        if (img == null) {
             return new Dimension(100,100);
        } else {
           return new Dimension(img.getWidth(null), img.getHeight(null));
       }
    }
 
   
}